package ccgl.com.dao;

import java.sql.Connection;
import java.sql.SQLException;

import ccgl.com.dao.common.BaseDao;
import ccgl.com.factory.ConnectionFactory;
import ccgl.com.model.DateItem;
import ccgl.com.model.MSp;
import ccgl.com.util.DateUtil;

/**
 * 信息统计管理Dao
 * 
 * @author Administrator
 * 
 */
public class XxtjDao extends BaseDao<MSp> {

	/**
	 * 得到一段时间内销售总额
	 * 
	 * @param dateItem
	 * @return
	 * @throws SQLException
	 */
	public float getTotalSaleroom(DateItem dateItem, String userId) {
		String sql = "select sum(ddzj) from ddb  where userid='" + userId
				+ "' and ddsj<='" + DateUtil.getDateStr(dateItem.getEndDate())
				+ "' and ddsj>='" + DateUtil.getDateStr(dateItem.getStarDate())
				+ "'";
		Connection con = null;
		try {
			con = ConnectionFactory.getConnection();
			return super.getSum(sql, con);
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			if (con != null) {
				try {
					con.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
		return 0;
	}
}
